import DBConnection from "../../service/unit/mysql/DBConnection";
export interface IData {
    user:string
    password:string
}

/**
 *
 * @param conn
 * @param data
 * @return true成功 false失败
 */
export default async function login(conn:DBConnection, data:IData){
    const result = await query(conn,data);
    if(result.length>0){

        return {storeId:result[0].id};
    }else{
        return {storeId:-1}
    }
}

function query(conn:DBConnection, data:IData) {
    const TABLE_NAME = 'user';
    const {user} = data;
    return conn.Query.queryWhere(TABLE_NAME,{name:user});
}